package com.candy.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapListHandler;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Test04 {
    public static void main(String[] args) {
        try {
            QueryRunner queryRunner=new QueryRunner(DBCPDataSource.getDataSource());
           List<Map<String,Object>> listmap= queryRunner.query("select * from userinfo",new MapListHandler());
            for (Map<String,Object> map:listmap
            ) {
//            取出所有key值放在set中
                Set se=map.keySet();
//            对set集合进行遍历
                for (Object ob:se
                ) {
                    System.out.print("列名："+ob+"\t"+"值："+map.get(ob)+"\t");
                }
                System.out.println();
            }



        } catch (SQLException e) {
            e.printStackTrace();
        }


    }



}
